
const {readDir, readFile} = require("./File");
const processFn = require('./process');

const list = () => {
    readDir('../figure').then((res) => {
        let nameList = '| '
        res.forEach((item) => {
            nameList += item.replace('.txt', ' | ');
        })
        console.log(nameList);
    }).catch((err) => {
        console.log(err)
    })

}

const blankSpace = '\xa0';
const enter = '\n';
const line = `${enter}${blankSpace.repeat(5)}\\${enter}${blankSpace.repeat(6)}\\${enter}`;
const listDetail = () => {
    readDir('../figure').then((res) => {
        res.forEach((item) => {
            const name = item.replace('.txt', '');
            readFile(`../figure/${name}.txt`).then((res) => {
                const say = `My name is ${name}`
                console.log(`${say}${line}${res}${enter.repeat(3)}`);
            }).catch((err) => {
                console.log(err);
            })
        })
    })
}

module.exports = {
    list,
    listDetail
}
